$(window).on('load', function () {
    getRatepayData();
});
/**
 *请求纳税总额数据
 * */
var getRatepayData = function () {
    SGIS.API.post("macro/get/realty/proportion").data({'year':2018}).json(function (re) {
        if(re){
            var lengend_data = [],data_val = [];
            var data = re.data;
            var unit = re.unit;
            var namearr = re.name;
            for(var i = 0 ;i < data.length ; i++){
                lengend_data.push(namearr[i]);
                data_val.push({
                    "name":namearr[i],
                    "value":data[i].toFixed(2)
                })
            }
            renderPieLeft(lengend_data,data_val,unit);
        }else{
            return;
        }
    });

}
/**
 *绘制饼图
 * */
var myChart_pie_l=''
var renderPieLeft = function (lengend_data,data_val,unit) {
    var dom = document.getElementById("scatter-map-pie-1");
    if(myChart_pie_l){
        myChart_pie_l.dispose()
    }
    myChart_pie_l = echarts.init(dom);
    var option = {
        tooltip: {
            trigger: 'item',
            formatter: "{b}: {c}"+unit+"({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            data:lengend_data
        },
        series: [
            {
                name:'数据',
                type:'pie',
                radius: ['50%', '70%'],
                color : ["#1dc8dc","#fcb445"],
                avoidLabelOverlap: false,
                label: {
                    normal: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '30',
                            fontWeight: 'bold'
                        }
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:data_val
            }
        ]
    };
    if (option && typeof option === "object") {
         myChart_pie_l.setOption(option, true);
    }
}
